<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>
                    <p:panel header="All Pharmacyutical Item report" >

                        <h:panelGrid columns="5" >
                            
                            <p:autoComplete converter="departmentConverter" completeMethod="#{departmentController.completeDept}" styleClass="noPrintButton"
                                            forceSelection="true"
                                            var="d" itemLabel="#{d.name}" itemValue="#{d}"
                                            value="#{pharmacySaleReport.department}" ></p:autoComplete>
                            <p:commandButton ajax="false" value="Process" 
                                            actionListener="#{pharmacySaleReport.fillNonMoving()}" ></p:commandButton>
                            <p:commandButton value="Print" ajax="false" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>
                            <p:commandButton value="Excel" ajax="false">
                                <pe:exporter type="xlsx" target="tbl" fileName="All_Items"
                                             facetFontStyle="BOLD" 
                                             fontName="Courier New" />
                            </p:commandButton>
                        </h:panelGrid>

                        <h:panelGroup id="gpBillPreview"  styleClass="noBorder summeryBorder" style="min-width: 100%!important;">

                            <p:dataTable id="tbl" rowIndexVar="ii" 
                                         value="#{pharmacySaleReport.nonMovingItems}" var="i" rowStyleClass="#{i.category eq null ? 'redText':'greenText'}"
                                 
                                         rows="50"
                                         paginator="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="20, 50, 100">
                                

                                <p:column width="40px;" headerText="No" sortBy="#{ii}">
                                    <h:outputLabel value="#{ii+1}" />
                                </p:column>

                                <p:column headerText="Code" width="50px;" sortBy="#{i.code}" filterBy="#{i.code}"
                                          filterMatchMode="startsWith">
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.code}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Item" width="300px;" sortBy="#{i.name}" filterBy="#{i.name}"
                                          filterMatchMode="contains">
                                    <f:facet name="header">
                                        <h:outputLabel value="Item"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.name}" ></h:outputLabel>
                                </p:column>

                                
                                <p:column headerText="Category" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Category"/>                                     
                                    </f:facet>
                                    <h:outputLabel value="#{i.category.name}"  >
                                        
                                    </h:outputLabel>
                                </p:column>



                            </p:dataTable>
                        </h:panelGroup>
                    </p:panel>
                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
